import {setTempCache, removeTempCache} from '../../utils/localStorage.js'

const reader = {
	state: {
		isRollVertical: false, // 是否纵向滚动
		showReadHeaderBar: false, // 是否展示ReadHeaderBar
		showReadMenuBar: false, // 是否展示ReadMenuBar
		currentReadCID: -1, //当前阅读的漫画id
		currentReadSID: -1, //当前阅读的章节id
		currentReadProgress: 0, //内容阅读的进度 从0开始的
		currentReadSections: null, //当前阅读的漫画章节信息
	},
	mutations: {
		'SET_ROLL_VERTICAL': (state, newVal) => {
			state.isRollVertical = newVal
		},
		'SET_SHOW_READ_HEADER_BAR': (state, newVal) => {
			state.showReadHeaderBar = newVal
		},
		'SET_SHOW_READ_MENU_BAR': (state, newVal) => {
			state.showReadMenuBar = newVal
		},
		'SET_CURRENT_READ_CID': (state, newVal) => {
			state.currentReadCID = newVal
		},
		'SET_CURRENT_READ_SID': (state, newVal) => {
			state.currentReadSID = newVal
		},
		'SET_CURRENT_READ_SECTIONS': (state, newVal) => {
			state.currentReadSections = newVal
		},
		'SET_CURRENT_READ_PROGRESS': (state, newVal) => {
			state.currentReadProgress = newVal
		},
	},
	actions: {
		setRollVertical: ({commit, state}, newVal) => {
			return commit('SET_ROLL_VERTICAL', newVal)
		},
		setShowReadHeaderBar: ({commit, state}, newVal) => {
			return commit('SET_SHOW_READ_HEADER_BAR', newVal)
		},
		setShowReadMenuBar: ({commit, state}, newVal) => {
			return commit('SET_SHOW_READ_MENU_BAR', newVal)
		},
		setCurrentReadCID: ({commit, state}, newVal) => {
			return commit('SET_CURRENT_READ_CID', newVal)
		},
		setCurrentReadSID: ({commit, state}, newVal) => {
			return commit('SET_CURRENT_READ_SID', newVal)
		},
		setCurrentReadSections: ({commit, state}, newVal) => {
			// session 缓存
			return commit('SET_CURRENT_READ_SECTIONS', newVal)
		},
		setCurrentReadProgress: ({commit, state}, newVal) => {
			return commit('SET_CURRENT_READ_PROGRESS', newVal)
		},
	}
}

export default reader